package jp.idahopotato.activity;

import jp.matome.activity.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

/**
 *
 * @author hiroki
 *
 */
public class Mhp3SkillSimuActivity extends Activity {

	private static final int SHOSW_CALC = 0;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.firstlayout);

		ListView menulist = (ListView)findViewById(R.id.menulist);
		menulist.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				ListView menulist = (ListView)parent;
				Intent intent = null;

				String menu = (String)menulist.getItemAtPosition(position);
				if(menu.equals("ハンタータイプ設定")){
					intent = new Intent(Mhp3SkillSimuActivity.this, TypeSetActivity.class);
				} else if(menu.equals("スキル条件設定")){
					intent = new Intent(Mhp3SkillSimuActivity.this, SkillSetActivity.class);
				} else if(menu.equals("お守り設定")){
					intent = new Intent(Mhp3SkillSimuActivity.this, OmamoriSetActivity.class);
				} else if(menu.equals("装備条件設定")){
					intent = new Intent(Mhp3SkillSimuActivity.this, ProtecSetActivity.class);
				} else if(menu.equals("防具使用条件設定")){
					intent = new Intent(Mhp3SkillSimuActivity.this, ProtecUseSetActivity.class);
				}

				intent.putExtra("SELECT_MENU", menu + "～前画面");
				startActivityForResult(intent, SHOSW_CALC);
			}
		});

		//検索
		Button searchBtn = (Button) findViewById(R.id.result);
		searchBtn.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				// TODO 自動生成されたメソッド・スタブ
				Intent intent = new Intent(Mhp3SkillSimuActivity.this, ResultListActivity.class);

				startActivityForResult(intent, SHOSW_CALC);
			}
		});

	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		//		super.onActivityResult(requestCode, resultCode, data);
		if(data != null && data.hasExtra("RETURN_FLAG")){
			Bundle extras = data.getExtras();
			String str = "";
			str = extras.getString("RETURN_FLAG");

			TextView view = (TextView)findViewById(R.id.testview);
			view.setText(str);
		}
	}
}